package com.cty._05_Ability._66_ConstructArray;

/**
 * @Auther: cty
 * @Date: 2020/7/25 16:44
 * @Description:
 * @version: 1.0
 */
public class ConstructArray {

    public static double[] constructArray(double[] A){
        if(A==null || A.length==0)
            return null;

        double[] B = new double[A.length];
        B[0] = 1;
        for(int i=1; i<A.length; i++)
            B[i] = B[i-1]*A[i-1];

        int temp = 1;
        for(int i=A.length-2; i>=0; i--){
            temp *= A[i+1];
            B[i] *= temp;
        }

        return B;
    }  // end constructArray()

}  // end class
